/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
	\file		CC_Layer.h
	\date		june 2010
	\author		TNick

	\brief		Contains the definition of CC_Layer class and related


	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Please read ReadMe.txt and Licence.txt in root folder
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef		__CC_LAYER_INC__
#define		__CC_LAYER_INC__
#ifdef		__cplusplus
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

class	CC_Draw;

#include	<QString>
#include	<generic/cc_l2dn.h>
#include	"CC_GraphItemProp.h"
#include	<base/uni_prp/PrpAgreg.h>
#include	<base/uni_prp/PrpHost.h>

/*  INCLUDES    ============================================================ */
//
//
//
//


/// Class representing a layer, no matter where is rooted
/**
*
*/

class	CC_Layer	: public CC_L2DN, public PrpHost
	{

	//
	//
	//
	//
	/*  DEFINITIONS    --------------------------------------------------------- */

	friend QAbstractItemModel*	CC_Draw::getStdIModel	(void);


	/*  DEFINITIONS    ========================================================= */
	//
	//
	//
	//
	/*  DATA    ---------------------------------------------------------------- */

protected:
	/// pointer to the drawing where this belongs
	CC_Draw*			pAscDraw;

	/// list of graphical items
	CC_HDL2D			Items;

	/// graphical data
	CC_GIP*				grd;

	/*  DATA    ================================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ----------------------------------------------------------- */

	/// function used to create a new layer
public: static CCERR::EERRORS		create		(
		CC_Draw*	pDraw,	/**< pointer to container; may be NULL */
		CC_Layer*	pTmpl,	/**< pointer to layer used as template; may be NULL */
		QString		strNewName,/**< name of this layer; must be either an empty
	 string or an unique name*/
		CC_Layer**	pOut,	/**< if succesfull, pointer to created layer */
		CC_Err*		pErr	/**< pointer to error correlation structure */
		);

	/// associates an unbound layer with a drawing
public: CCERR::EERRORS				bind		(
		CC_Draw*	pDraw,	/**< pointer to container; must not be NULL */
		CC_Err*		pErr	/**< pointer to error correlation structure */
		);

	/// constructor
public:						CC_Layer	() : CC_L2DN()
	{ pAscDraw = NULL; grd = NULL; }

	/// destructor; will free resources;
public: virtual				~CC_Layer	();



	/// gets an unique name for a drawing
public:	static QString		uniqName	(
		CC_Draw*	pDraw,	/**< target drawing */
		CC_Err*		pErr	/**< pointer to error correlation structure */
		);

	/// tells if a particular drawing contains a given layer name
public:	static bool			hasLayer	(
		CC_Draw*	pDraw,	/**< target drawing */
		QString		strTst,	/**< string to test (case insensitive) */
		CC_Err*		pErr	/**< pointer to error correlation structure */
		);




	/* >>>>>>>>>>>>>>>>>>>>>>>>>>>   PrpHost   <<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
	/// get the list of properties a a list of pointers to PrpAgreg instances
	/**
	*	@return		array allocated using new[]; the ownership of the array
		 passes to caller; may be NULL for memory failures or if the item
		 has no properties
	*/
	virtual PrpAgreg**	propList		(
		int*		p_count	/**< pointer to variable that recives
		the number of elements in the list */
	) const { *p_count = 0; return NULL; }


	/// informs the item about a chnge in properties
	/**
	*	the item must determine inside if it supports this property and,
	*	if it does, shall update it's value. If the item does not support
	*	this feature, it should silently ignore this call.
	*/
	virtual void		propChanged		(
		PrpAgreg*	p_new_val	/**< pointer to changed value */
	) { Q_UNUSED(p_new_val); }



	/* >>>>>>>>>>>>>>>>>>>>>>>>>>>  FILE I/O   <<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
	/// saves the data regarding this class to a stream in CASP_1 format
	/*
	*	@return		true all went OK; false some went wrong
	*/
public: CCERR::EERRORS		Save_CASP_1	(QDataStream* pStream, CC_Err* pErr);


	/// loads the data regarding this class from a stream in CASP_1 format
	/*
	*	@return		true all went OK; false some went wrong
	*/
public: CCERR::EERRORS		Load_CASP_1	(QDataStream* pStream, CC_Err* pErr);


	/// saves the data regarding this class to a stream in DXF format
	/*
	*	@return		true all went OK; false some went wrong
	*/
public: CCERR::EERRORS		Save_DXF	(QDataStream* pStream, CC_Err* pErr);


	/// loads the data regarding this class from a stream in DXF format
	/*
	*	@return		true all went OK; false some went wrong
	*/
public: CCERR::EERRORS		Load_DXF	(QDataStream* pStream, CC_Err* pErr);



	/*  FUNCTIONS    =========================================================== */
	//
	//
	//
	//

	};	/*	class	CC_Layer	*/

//
//
//
//
#endif	//	__cplusplus
#endif	//	__CC_LAYER_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
